package org.semanticflash.rdf.values
{
	
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import com.bigflexlib.x.flash.system.gc.GCUtil;
	
	
	
	[ExcludeClass]
	public class RDFValueCache
	{
		
		
		
		/**
		 * 
		 * The actual cache hashmap
		 * 
		 * 
		 */		
		internal var cache:Object = { };
		
	
	
		private var timer:Timer;
	
	
		// TODO: find a better heuristic ( by checking mem or the amount of RDFValues in the cache )
		public function RDFValueCache( )
		{
			
			var delay:int = 5 * 1000 * 60; // 5 minutes
	
			timer = new Timer( delay, 0 );

			timer.addEventListener( TimerEvent.TIMER, timer_complete );

			timer.start( );
	
		}
		
		
		
		
		private function timer_complete( event:TimerEvent ):void
		{
			GCUtil.gcMapValues( cache );
		}
		
		
		

		
		
	







		private static var _i:RDFValueCache;

		internal static function get i( ):RDFValueCache
		{
			if ( _i == null )
				_i = new RDFValueCache( );
			return _i;
		}




	}
}
